package org.example.controller;

import lombok.extern.slf4j.Slf4j;
import org.example.commonapi.domain.R;
import org.example.commonapi.domain.RecommendWord;
import org.example.commonapi.domain.Video;
import org.example.commonapi.vo.VideoVO;
import org.example.service.AiRecommendService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * 存放ai推荐的Controller
 */

@RestController
@RequestMapping("/aiChat")
@Slf4j
public class AiRecommendController {

    @Autowired
    private AiRecommendService aiRecommendService;

    /**
     * 通过正在观看的视频 让ai从数据库中推荐几个类似的视频
     * @param videoId
     * @return
     */
    @GetMapping("/getAiRecommendVideo")
    public R<List<VideoVO>> getAiRecommendVideo(@RequestParam("videoId") Integer videoId) {
        return aiRecommendService.getAiRecommendVideo(videoId);
    }

    /**
     * 根据教学内容推荐视频
     * @param chapterTitle
     * @return
     */
    @GetMapping("/getVideoListByTeachContent")
    public R<List<VideoVO>> getVideoListByTeachContent(@RequestParam String chapterTitle){
        return aiRecommendService.getVideoListByTeachContent(chapterTitle);
    }


    /**
     * 根据学科获取首页ai推荐的视频
     * @param subject
     * @return
     */
    @GetMapping("/getHomeRecommendVideo")
    public R<List<VideoVO>> getHomeRecommendVideo(@RequestParam("subject") String subject) {
        return aiRecommendService.getHomeRecommendVideo(subject);
    }

    /**
     * 获取ai推荐的个性化视频
     * @param request
     * @return
     */
    @GetMapping("/getAiPersonalityVideo")
    public R<List<VideoVO>> getAiPersonalityVideo(HttpServletRequest request) {
        return aiRecommendService.getAiPersonalityVideo(request);
    }

    /**
     * 当翻译完成之后 ai根据用户翻译语句 翻译语种 进行个性化推荐
     * @param text
     * @param from
     * @param to
     * @return
     */
    @GetMapping("/getAiRecommendWord")
    public R<List<RecommendWord>> aiRecommendWord(@RequestParam("text") String text,@RequestParam("from") String from,@RequestParam("to") String to) {
        return aiRecommendService.aiRecommendWord(text,from,to);
    }

    /**
     * 获取指定科目的ai推荐的视频
     * @param subject
     * @return
     */
    @GetMapping("/getAiRecommendTargetSubjectVideo")
    public R<List<VideoVO>> getAiRecommendTargetSubjectVideo(@RequestParam("subject") String subject) {
        return aiRecommendService.getAiRecommendTargetSubjectVideo(subject);
    }

    /**
     * 获取 根据刷题情况 课程情况 视频情况三个纬度让ai进行打分评价并推荐之后如何学习 的推荐词
     * @param request
     * @return
     */
    @GetMapping("/getAiJudgeAndRecommendBySynthesis")
    public R<String> getAiJudgeAndRecommendBySynthesis(HttpServletRequest request) {
        return aiRecommendService.getAiJudgeAndRecommendBySynthesis(request);
    }

    /**
     * 获取 根据用户观看视频的情况进行总结和推荐 的提示词
     * @param request
     * @return
     */
    @GetMapping("/getAiJudgeAndRecommendByVideo")
    public R<String> getAiJudgeAndRecommendByVideo(HttpServletRequest request) {
        return aiRecommendService.getAiJudgeAndRecommendByVideo(request);
    }

    /**
     * 获取 根据用户进行的练习进行总结和推荐 的提示词
     * @param request
     * @return
     */
    @GetMapping("/getAiJudgeAndRecommendByPractice")
    public R<String> getAiJudgeAndRecommendByPractice(HttpServletRequest request) {
        return aiRecommendService.getAiJudgeAndRecommendByPractice(request);
    }

    /**
     * 练习提交答案
     * @param id
     * @param answer
     * @param request
     * @return
     */
    @PostMapping("/submitPracticeAnswer")
    public R<String> submitPracticeAnswer(@RequestParam Integer id,@RequestParam String answer,HttpServletRequest request)  {
        return aiRecommendService.submitPracticeAnswer(id,answer,request);
    }

    /**
     * 获取ai给的提示
     * @param id
     * @return
     */
    @GetMapping("/getAiTip")
    public R<String> getAiTip(@RequestParam Integer id){
        return aiRecommendService.getAiTip(id);
    }





}
